/**
 * RevenueSourceFactory.java
 * Created on March 21, 2007, 10:04 PM
 *
 *
 */

package edu.byu.isys413.jjenkins.data;

import java.util.Map;
import java.util.TreeMap;

/**
 * This class selects the proper revenueSourceDAO based on a String type
 * and returns it. 
 *
 * @author      Jeff Jenkins
 * @version     1.0
 */
public class RevenueSourceFactory {
    
    private static RevenueSourceFactory instance = null;
    Map<String, RevenueSourceDAO> factory; 
    
    /** Creates a new instance of RevenueSourceFactory*/
    private RevenueSourceFactory() {
        factory = new TreeMap();
        factory.put("example", ExampleSubRevSourceDAO.getInstance()); 
        
        /*TODO add the other revenuesources */
    }
    
    /*This mehod ensures that only one instance of revenueSourceFactory
     *exists */
    
     public static synchronized RevenueSourceFactory getInstance() {
        if (instance == null) {
            instance = new RevenueSourceFactory();
        }
        return instance;
    }
    
    /*This method returns the appropriate sub revenuesourceDAO based on the 
     *string that is passed in
     *
     *@param String name of the revenue soruce
     */
     
    public RevenueSourceDAO getDAO(String name){
        
        return factory.get(name);
    }
    
}
